<template>
	<view>
		<view class="pd10 plr15 whiteBg">
			<input :focus="true" :adjust-position="false" @confirm="confirm" type="text" v-model="name" class="block" placeholder="输入企业全名搜索">
		</view>
		<block v-if="!!data.noMsg">
			<empty :list="[]" tips="抱歉,暂无企业信息~"></empty>
		</block>
		<block v-else-if="data.name">
			
			<result :title="data.name" :desc="data.address" icon="icon-bangding iconfont" iconColor="#3385ff">
				<view class="btn shadow md gradualBg rds23" @tap="confirmBind">
					确认绑定
				</view>
				<view class="pt20 text-center" @tap="data={};name='';">
					取消
				</view>
			</result>
			
		</block>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data : {} ,
				name : ""
			}
		},
		methods: {
			confirm:function(e){
				this.name = e.detail.value ;
				var data = {name:this.name} ;
				uni.showLoading({
					title: "查询中…"
				});
				this.kit.get("/api/company/search",data,res => {
					uni.hideLoading();
					this.data = res.data || {noMsg:true} ;
				});
			},
			
			confirmBind:function(e){
				var data = {id:this.data.id} ;
				this.kit.get("/api/servicerCompany/save",data,res => {
					this.kit.goBack();
					setTimeout(e => {
						uni.showToast({
							title: '绑定成功',
							icon : 'success'
						});
					},200);
				});
			},
		}
	}
</script>

<style>

</style>
